namespace Home.Domain.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Bulletin",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 60),
                        Body = c.String(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.UserInfo",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 32),
                        PassWord = c.String(nullable: false, maxLength: 64),
                        Name = c.String(maxLength: 16),
                        Email = c.String(maxLength: 64),
                        CompanyName = c.String(maxLength: 32),
                        Position = c.String(maxLength: 32),
                        Phone = c.String(maxLength: 32),
                        Address = c.String(maxLength: 64),
                        State = c.Int(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.News",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(maxLength: 64),
                        Body = c.String(nullable: false),
                        Tags = c.String(maxLength: 200),
                        Description = c.String(maxLength: 250),
                        Source = c.String(maxLength: 200),
                        CreateDate = c.DateTime(nullable: false),
                        PNewsId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.PNews", t => t.PNewsId, cascadeDelete: true)
                .Index(t => t.PNewsId);
            
            CreateTable(
                "dbo.PNews",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 64),
                        Sort = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Article",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ArticleId = c.Int(nullable: false),
                        Type = c.Int(nullable: false),
                        Level = c.Int(nullable: false),
                        Body = c.String(nullable: false),
                        Sort = c.Single(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.News", new[] { "PNewsId" });
            DropForeignKey("dbo.News", "PNewsId", "dbo.PNews");
            DropTable("dbo.Article");
            DropTable("dbo.PNews");
            DropTable("dbo.News");
            DropTable("dbo.UserInfo");
            DropTable("dbo.Bulletin");
        }
    }
}
